﻿<loki:ViewWindow
    xmlns:loki="clr-namespace:Loki.UI.Wpf;assembly=Loki.UI.Wpf"
    xmlns:lc="clr-namespace:Loki.Commands;assembly=Loki.Core"
    xmlns:luna="clr-namespace:Luna.UI;assembly=Luna.Core"
    xmlns:local="clr-namespace:Luna.UI.Wpf"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dxwui="http://schemas.devexpress.com/winfx/2008/xaml/windowsui"

    xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
    xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
    xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
    x:TypeArguments="luna:MainViewModel"
    x:Class="Luna.UI.Wpf.MainTiles"
    Title="Luna"  WindowStartupLocation="CenterOwner"
    WindowState="Maximized"
    Icon="Resources/Moon_Phase_Full.png" BorderEffect="Default" EnableTransparency="False" WindowStyle="ThreeDBorderWindow">
    <Window.Resources>
        <Style TargetType="dxg:GridControl">
            <Setter Property="MaxHeight" Value="2000" />
            <Setter Property="Margin" Value="50" />
        </Style>
        <Style TargetType="dxb:BarButtonItem" x:Key="MNI_Style">
            <Setter Property="BarItemDisplayMode" Value="Default" />
            <Style.Triggers>
                <DataTrigger Binding="{Binding Command.Tag}" Value="Application.New">
                    <Setter Property="LargeGlyph" Value="{StaticResource MNI_add}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Command.Tag}" Value="Application.Save">
                    <Setter Property="LargeGlyph" Value="{StaticResource MNI_save}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Command.Tag}" Value="Application.Refresh">
                    <Setter Property="LargeGlyph" Value="{StaticResource MNI_refresh}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Command.Tag}" Value="Application.Google.Refresh">
                    <Setter Property="LargeGlyph" Value="{StaticResource MNI_google}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Command.Tag}" Value="Application.Zoho.Refresh">
                    <Setter Property="LargeGlyph" Value="{StaticResource MNI_zoho}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Command.Tag}" Value="Application.Search">
                    <Setter Property="LargeGlyph" Value="{StaticResource MNI_search}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Command.Tag}" Value="Data.Open">
                    <Setter Property="LargeGlyph" Value="{StaticResource MNI_open}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Command.Tag}" Value="Application.Export">
                    <Setter Property="LargeGlyph" Value="{StaticResource MNI_excel}" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
        <DataTemplate x:Key="mni_template">
            <ContentControl>
                <dxb:BarButtonItem Content="{Binding Name}"
                                   GlyphAlignment="Top"
                                   GlyphSize="Large"
                                   BarItemDisplayMode="Default"
                                   Command="{Binding Command}"
                                   Style="{StaticResource MNI_Style}" />
            </ContentControl>
        </DataTemplate>
        <BooleanToVisibilityConverter  x:Key="CVT_BoolToVisibiliy" />
        <DoubleAnimation x:Key="ShowSearchAnimation" Storyboard.TargetProperty="Width" To="250" Duration="0:0:0.2" />
        <DoubleAnimation x:Key="HideSearchAnimation" Storyboard.TargetProperty="Width" To="0" Duration="0:0:0.2" />
    </Window.Resources>
    <dxb:BarManager>
        <dxb:BarManager.Bars>
            <dxb:Bar x:Name="mainMenuBar" Caption="Main Menu" IsMainMenu="True" UseWholeRow="True" DataContext="{Binding Menu}"  ItemTemplate="{StaticResource mni_template}"  ItemLinksSource="{Binding Commands}" ItemLinksSourceElementGeneratesUniqueBarItem="True">
                <dxb:Bar.DockInfo>
                    <dxb:BarDockInfo ContainerType="Right" />
                </dxb:Bar.DockInfo>
            </dxb:Bar>
        </dxb:BarManager.Bars>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="250" />
            </Grid.ColumnDefinitions>
            <Grid.Background>
                <ImageBrush ImageSource="{StaticResource BACK}" Stretch="UniformToFill" />
            </Grid.Background>
            <StackPanel Background="Black" Width="0" x:Name="PNL_Search" Grid.ZIndex="1" Grid.Column="1" HorizontalAlignment="Right" MouseLeave="PNL_Search_MouseLeave">
                <StackPanel.Style>
                    <Style>
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding SearchActive}" Value="True">
                                <DataTrigger.EnterActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <StaticResource ResourceKey="ShowSearchAnimation" />
                                        </Storyboard>
                                    </BeginStoryboard>
                                </DataTrigger.EnterActions>
                                <DataTrigger.ExitActions>
                                    <BeginStoryboard>
                                        <Storyboard>
                                            <StaticResource ResourceKey="HideSearchAnimation" />
                                        </Storyboard>
                                    </BeginStoryboard>
                                </DataTrigger.ExitActions>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </StackPanel.Style>
                <!--<VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="Searching">
                        <VisualStateGroup.Transitions>
                            <VisualTransition From="Disabled" To="Enabled" GeneratedDuration="0:0:1">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="PNL_Search" Storyboard.TargetProperty="(UIElement.Visibility)">
                                        <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <DoubleAnimation Duration="0:0:1" Storyboard.TargetName="PNL_Search" Storyboard.TargetProperty="(StackPanel.Width)" From="0" To="250">
                                        <DoubleAnimation.EasingFunction>
                                            <ElasticEase EasingMode="EaseInOut" />
                                        </DoubleAnimation.EasingFunction>
                                    </DoubleAnimation>
                                </Storyboard>
                            </VisualTransition>
                            <VisualTransition From="Enabled" To="Disabled" GeneratedDuration="0:0:1">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="PNL_Search" Storyboard.TargetProperty="(UIElement.Visibility)">
                                        <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Collapsed}" />
                                    </ObjectAnimationUsingKeyFrames>
                                    <DoubleAnimation Duration="0:0:1" Storyboard.TargetName="PNL_Search" Storyboard.TargetProperty="(StackPanel.Width)" From="250" To="0">
                                        <DoubleAnimation.EasingFunction>
                                            <ElasticEase EasingMode="EaseInOut" />
                                        </DoubleAnimation.EasingFunction>
                                    </DoubleAnimation>
                                </Storyboard>
                            </VisualTransition>
                        </VisualStateGroup.Transitions>

                        <VisualState x:Name="Disabled">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="PNL_Search" Storyboard.TargetProperty="(UIElement.Visibility)">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Collapsed}" />
                                </ObjectAnimationUsingKeyFrames>
                                <DoubleAnimation Duration="0:0:0" Storyboard.TargetName="PNL_Search" Storyboard.TargetProperty="(StackPanel.Width)" To="0" />
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Enabled">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Duration="0:0:0" Storyboard.TargetName="PNL_Search" Storyboard.TargetProperty="(UIElement.Visibility)">
                                    <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{x:Static Visibility.Visible}" />
                                </ObjectAnimationUsingKeyFrames>
                                <DoubleAnimation Duration="0:0:0" Storyboard.TargetName="PNL_Search" Storyboard.TargetProperty="(StackPanel.Width)" To="250" />
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>-->
            </StackPanel>
            <dxwui:NavigationFrame Grid.ZIndex="0" Grid.Column="0"  Grid.ColumnSpan="2"  x:Name="FRM_Navigation"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Source="NavigationMenu"  AnimationType="SlideHorizontal" BackNavigationMode="Root" />
        </Grid>
    </dxb:BarManager>
</loki:ViewWindow>